<script setup>
import ChangeInfo from './components/ChangeInfo.vue'
import ChangePassword from './components/ChangePassword.vue'
import MyInfo from './components/MyInfo.vue'
import MyApi from '../../service/api/my/my'
const activeName = ref('first')
import { ref, onMounted } from 'vue'
const tableForm = ref()
onMounted(() => {
  MyApi.getMyInfo().then((res) => {
    console.log(res)
    if (res.code === 200) {
      tableForm.value = res.data
    }
  })
})

// 刷新
const refreshData = async () => {
  await MyApi.getMyInfo().then((res) => {
    console.log(res)
    if (res.code === 200) {
      tableForm.value = { ...res.data }
    }
  })
}
</script>

<template>
  <div class="info-page">
    <div class="super-wrapper"></div>
    <el-card class="info-container" :body-style="{ width: '100%', padding: '6px' }">
      <el-tabs v-model="activeName" @tab-click="handleClick" class="tabs">
        <el-tab-pane label="我的信息" name="first">
          <MyInfo :tableForm="tableForm" @success="refreshData" />
        </el-tab-pane>
        <el-tab-pane label="修改信息" name="second" @success="refreshData">
          <ChangeInfo :tableForm="tableForm" />
        </el-tab-pane>
        <el-tab-pane label="修改密码" name="third">
          <ChangePassword />
        </el-tab-pane>
      </el-tabs>
    </el-card>
  </div>
</template>

<style scoped lang="scss">
.info-page {
  .info-container-title {
    display: flex;
    align-items: center;
    width: 100%;
    height: 40px;
    padding-bottom: 0px;
    line-height: 20px;
    border-bottom: 1px solid #ccc;
  }
  .el-card {
    margin: 20px;
  }
  .is-always-shadow {
    width: 0;
  }

  display: flex;
  flex-direction: row;
  .info-container {
    height: 100%;
    flex-grow: 5;
    .tabs {
      height: 70vh;
    }
  }
}
</style>
